home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_aet_doortalk.cog < prev    next >
Text File  |  1999-11-15  |  16KB  |  581 lines

  1. # Jones 3D Cog Script
  2. #
  3. # aet_DoorTalk.cog
  4. #
  5. # Indy talks a lot around doors
  6. #
  7. # [HB; thanks to Pat M & Tim M] and [TL] for small additions...
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ==============================================================================
  11.  
  12. # NOTE: This is a random verbal door reaction cog.  Glue it into your level and
  13. # reach it from a calling cog like this:
  14. #
  15. # 1. Create a valid reference to this cog in your calling cog;
  16. #
  17. # 2. Use the following verb:
  18. #    SendMessageEx(thiscogREF, i_userMessage, f_parm0, f_parm1, f_parm2, f_parm3);
  19. #    (see each section below for details...)
  20. #
  21. # 3. Use global15 as a semaphore and return value where neeeded;
  22. #
  23. # The resulting chatter is pre-approved by HB...
  24. #
  25. # PRODUCT SUPPORT:  cogsrus x8371
  26.  
  27. # ==============================================================================
  28.  
  29. symbols
  30.  
  31. # ................................. MESSAGES ...................................
  32.  
  33.     message user0    # locked door reaction: right key, wrong key, wrong item, no item
  34.     message user1    # right key
  35.     message user2    # wrong key
  36.     message user3    # wrong item
  37.     message user4    # no item
  38.     message user5    # things that won't open
  39.  
  40. # ................................. SAY LINES ..................................
  41.  
  42.     # right key lines...
  43.     sound    in_sayline=Inxj110.wav                local # Success!-->in_sayline[0]
  44.     sound    in_there=Inxj108.wav                local # There!
  45.     sound    in_fits=Inxj108.wav                    local # There! **bug fix...changed line here [TL]**
  46.     sound    in_whoaopen=Inxj103.wav                local # Whoa! It opened.
  47.     sound    in_worked=Inxj111.wav                local # what...know...worked!
  48.     sound    in_gotlucky=Inxj106.wav                local # ...got lucky.
  49.     sound    in_damnopen=Inxj105.wav                local # ...be damned...opened.
  50.     
  51.     # wrong key lines...
  52.     sound    in_mustwrongkey=Inxj083.wav            local # Hmm...wrong key-->in_sayline[7]
  53.     sound    in_wrongkey=Inxj084.wav                local # Wrong key.
  54.     sound    in_guesswrongkey=Inxj085.wav        local # I guess...wrong key.
  55.     sound    in_ifkeywrong=Inxj086.wav            local # If key...wrong key.
  56.  
  57.     # wrong item lines...
  58.     sound    in_nowork=Inxj089.wav                local # That didn't work-->in_sayline[11]
  59.     sound    in_somethingwrong=Inxj090.wav        local # ...something wrong.
  60.     sound    in_hmnotquite=Inxj092.wav            local # Hmm...didn't quite work.
  61.     sound    in_notright=Inxj060.wav                local # I don't think...right answer
  62.     sound    in_whoops=Inxj087.wav                local # Whoops.
  63.     sound    in_nope=Inxj088.wav                    local # Nope.
  64.     sound    in_ofcourseno=Inxj091.wav            local # Of course that didn't work.    
  65.  
  66.     # door locked lines...
  67.     sound    in_doorlocked=Inxj076.wav            local # This...locked-->in_sayline[18]
  68.     sound    in_islocked=Inxj077.wav                local # It's locked.
  69.     sound    in_locked=Inxj078.wav                local # Locked.
  70.     sound    in_keyhole=Inxj078.wav                local # Locked. **bug fix...changed line here [TL]**
  71.     sound    in_lockedagain=Inxj079.wav            local # Locked again.
  72.     sound    in_lockedluck=Inxj080.wav            local # Locked...luck never changes.
  73.     sound    in_whyalwayslocked=Inxj081.wav        local # Oh no...why...always locked?
  74.  
  75.     # just won't open lines...
  76.     sound    in_cantopen=Inxj096.wav                local # I can't open it-->insayline[25]
  77.     sound    in_somereadon=Inxj097.wav            local # For some reason...won't open.
  78.     sound    in_nobudge=Inxj098.wav                local # It won't budge.
  79.     sound    in_holdingdoor=Inxj099.wav            local # Something is holding this door closed.
  80.     sound    in_dontknow=Inxj102.wav                local # must be way...don't know how.
  81.  
  82. # ............................... VARIABLES ....................................
  83.  
  84.     flex    talkerREF                            local
  85.     flex    rightItem                            local
  86.     flex    triedItem                            local
  87.     flex    forceTalk                            local
  88.     flex    forceLine                            local
  89.     
  90.     int        key=53                                local # tikikey == key[0]
  91.     int        monkeykey=54                        local
  92.     int        h20key=55                            local
  93.     int        divrm1key=58                        local
  94.     int        divrm2key=59                        local
  95.     int        padkey=61                            local
  96.     int        elevkey=68                            local
  97.     int        pyramidkey=84                        local
  98.     int        sharkkey=85                            local
  99.     int        sealkey=87                            local
  100.     int        squarekeys=98                        local # keys plural?
  101.     int        tikikey2=99                            local
  102.     int        turnerkey=102                        local
  103.     int        bronzekey=103                        local
  104.     int        cuffkey=110                            local
  105.     int        oldladykey=115                        local
  106.     int        sharkgatekey=116                    local
  107.  
  108.     int        keyindex                            local # indexes int array
  109.     int        keyItem                                local # flags wrong key use
  110.     int        keytotal=17                            local # define total number of keys
  111.  
  112.     int        lineindex                            local # indexes sound array
  113.     int        rightkeyoffset=0                    local # define
  114.     int        wrongkeyoffset=7                    local # define 
  115.     int        wrongitemoffset=11                    local # define
  116.     int        lockoffset=18                        local # define
  117.     int        wontopenoffset=25                    local # define
  118.  
  119.     int        alreadyworking=0                    local
  120.  
  121.     int        rk_newline=50                        local # init outside actual range
  122.     int        rk_oldline=50                        local
  123.     int        wk_newline=50                        local
  124.     int        wk_oldline=50                        local
  125.     int        wi_newline=50                        local
  126.     int        wi_oldline=50                        local
  127.     int        dl_newline=50                        local
  128.     int        dl_oldline=50                        local
  129.     int        wo_newline=50                        local
  130.     int        wo_oldline=50                        local
  131.  
  132.     int        dummy
  133.     
  134.     flex    checkforkey                            local
  135.     flex    randrightkeylines                    local
  136.     flex    randwrongkeylines                    local
  137.     flex    randwrongitemlines                    local
  138.     flex    randlocklines                        local
  139.     flex    randwontopenlines                    local
  140.  
  141. end
  142.  
  143. # ==============================================================================
  144.  
  145. code
  146.  
  147. # ..............................................................................
  148.  
  149. user0:
  150.  
  151.     # Indy reacts verbally to a locked door player has ACTIVATED in some way...
  152.     #
  153.     # Proper command to reach this response section from the calling cog is:
  154.     #
  155.     # SendMessageEx(lockdoorcogREF, user0, f_talkerREF, f_rightItem, f_triedItem, 0);
  156.     #
  157.     # global15 is used by this cog and the calling cog, like so:
  158.     #
  159.     # global15 == 0 while this cog is at work (waiting for line to finish)
  160.     # global15 == 1 upon return if the player failed to open the door
  161.     # global15 == 2 upon return if the player succeeded
  162.     #
  163.     # The calling cog can use the 0 value as a semaphore to pause execution, thus:
  164.     #
  165.     # while (global15 == 0)
  166.     # {
  167.     #    # Wait for line to finish...
  168.     #    Sleep(0.01);
  169.     # }
  170.  
  171.     if (alreadyworking > 0)
  172.     {
  173.         return;
  174.     }
  175.  
  176.     global15 = 0; # init each call
  177.  
  178.     talkerREF = GetParam(0); # is player or an actor talking? (a cast!)
  179.     rightItem = GetParam(1); # what player must use
  180.     triedItem = GetParam(2); # what player did use
  181.     
  182.     alreadyworking = 1; # stall multiple calls
  183.     
  184.     if (rightItem == triedItem)
  185.     {
  186.         # player has right key and is using it properly
  187.         call randrightkeylines;
  188.         global15 = 2;
  189.     }
  190.     else
  191.     {
  192.         if (triedItem == 0)
  193.         {
  194.             # player isn't using anything
  195.             call randlocklines;
  196.             global15 = 1;
  197.         }
  198.         else
  199.         {
  200.             call checkforkey;
  201.             if (keyItem != 0)
  202.             {
  203.                 # player is using the wrong key
  204.                 call randwrongkeylines;
  205.                 global15 = 1;
  206.             }
  207.             else
  208.             {
  209.                 # player is using a wrong non-key item
  210.                 call randwrongitemlines;
  211.                 global15 = 1;
  212.             }
  213.         }
  214.     }
  215.         
  216.     alreadyworking = 0; # clear to call again
  217.  
  218.     return;
  219.         
  220. # ........................................................................................
  221.  
  222. user1:
  223.  
  224.     # NOTE: Indy notes success with RIGHT KEY without taking any other action...
  225.     #
  226.     # Proper command to reach this response section from the calling cog is:
  227.     #
  228.     # SendMessageEx(doortalkcogREF, user1, f_talkerREF, f_forceTalk, f_forceLine, 0);
  229.     #
  230.     # global15 is used here like so:
  231.     #
  232.     # global15 == 0 while this cog is at work (waiting for line to finish)
  233.     # global15 == 1 upon return
  234.     #
  235.     # As discussed in user0 section, the calling cog can use global15 as a semaphore
  236.     #
  237.     # Hey!  You can also force a line choice.  Here's how:
  238.     # 1. Note your intention by setting f_forceTalk parm to some non-zero value
  239.     # 2. Examine the available lines to find the one you want (counting from 0)
  240.     # 3. Pass that number in the forceLine parameter (parm2) 
  241.  
  242.     if (alreadyworking > 0)
  243.     {
  244.         return;
  245.     }
  246.  
  247.     global15 = 0; # init each call
  248.  
  249.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  250.     forceTalk = GetParam(1); # force a choice
  251.     forceLine = GetParam(2); # actual line choice
  252.     
  253.     alreadyworking = 1; # stall multiple calls
  254.  
  255.     if (forceTalk > 0)
  256.     {
  257.         rk_newline = forceLine; # choose this line
  258.         rk_oldline = 0;
  259.     }
  260.  
  261.     call randrightkeylines;
  262.     global15 = 1;
  263.     alreadyworking = 0;
  264.  
  265.     return;
  266.  
  267. # ........................................................................................
  268.  
  269. user2:
  270.  
  271.     # NOTE: Indy notes player has tried WRONG KEY... 
  272.     #
  273.     # Proper command to reach this response section from the calling cog is:
  274.     #
  275.     # SendMessageEx(doortalkcogREF, user2, f_talkerREF, f_forceTalk, f_forceLine, 0);
  276.     #
  277.     # global15 is used here like so:
  278.     #
  279.     # global15 == 0 while this cog is at work (waiting for line to finish)
  280.     # global15 == 1 upon return
  281.     #
  282.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  283.     #
  284.     # As discussed in user1 section, you can also force a line choice.
  285.  
  286.     if (alreadyworking > 0)
  287.     {
  288.         return;
  289.     }
  290.  
  291.     global15 = 0; # init each call
  292.  
  293.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  294.     forceTalk = GetParam(1); # force a choice
  295.     forceLine = GetParam(2); # actual line choice
  296.     
  297.     alreadyworking = 1; # stall multiple calls
  298.  
  299.     if (forceTalk > 0)
  300.     {
  301.         wk_newline = forceLine; # choose this line
  302.         wk_oldline = 0;
  303.     }
  304.  
  305.     call randwrongkeylines;
  306.     global15 = 1;
  307.     alreadyworking = 0;
  308.  
  309.     return;
  310.  
  311. # ........................................................................................
  312.  
  313. user3:
  314.  
  315.     # NOTE: Indy notes use of a WRONG ITEM...
  316.     #
  317.     # Proper command to reach this response section from the calling cog is:
  318.     #
  319.     # SendMessageEx(doortalkcogREF, user3, f_talkerREF, f_forceTalk, f_forceLine, 0);
  320.     #
  321.     # global15 is used here like so:
  322.     #
  323.     # global15 == 0 while this cog is at work (waiting for line to finish)
  324.     # global15 == 1 upon return
  325.     #
  326.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  327.     #
  328.     # As discussed in user1 section, you can also force a line choice.
  329.  
  330.     if (alreadyworking > 0)
  331.     {
  332.         return;
  333.     }
  334.  
  335.     global15 = 0; # init each call
  336.  
  337.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  338.     forceTalk = GetParam(1); # force a choice
  339.     forceLine = GetParam(2); # actual line choice
  340.     
  341.     alreadyworking = 1; # stall multiple calls
  342.  
  343.     if (forceTalk > 0)
  344.     {
  345.         wi_newline = forceLine; # choose this line
  346.         wi_oldline = 0;
  347.     }
  348.  
  349.     call randwrongitemlines;
  350.     global15 = 1;
  351.     alreadyworking = 0;
  352.  
  353.     return;
  354.  
  355. # ........................................................................................
  356.  
  357. user4:
  358.  
  359.     # NOTE: Indy acknowledges a LOCKED DOOR...
  360.     #
  361.     # Proper command to reach this response section from the calling cog is:
  362.     #
  363.     # SendMessageEx(doortalkcogREF, user4, f_talkerREF, f_forceTalk, f_forceLine, 0);
  364.     #
  365.     # global15 is used here like so:
  366.     #
  367.     # global15 == 0 while this cog is at work (waiting for line to finish)
  368.     # global15 == 1 upon return
  369.     #
  370.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  371.     #
  372.     # As discussed in user1 section, you can also force a line choice.
  373.  
  374.     if (alreadyworking > 0)
  375.     {
  376.         return;
  377.     }
  378.  
  379.     global15 = 0; # init each call
  380.  
  381.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  382.     forceTalk = GetParam(1); # force a choice
  383.     forceLine = GetParam(2); # actual line choice
  384.     
  385.     alreadyworking = 1; # stall multiple calls
  386.  
  387.     if (forceTalk > 0)
  388.     {
  389.         dl_newline = forceLine; # choose this line
  390.         dl_oldline = 0;
  391.     }
  392.  
  393.     call randlocklines;
  394.     global15 = 1;
  395.     alreadyworking = 0;
  396.  
  397.     return;
  398.  
  399. # ........................................................................................
  400.  
  401. user5:
  402.  
  403.     # NOTE: Indy notes a DOOR with no obvious lock that JUST WON'T OPEN...
  404.     #
  405.     # Proper command to reach this response section from the calling cog is:
  406.     #
  407.     # SendMessageEx(doortalkcogREF, user5, f_talkerREF, f_forceTalk, f_forceLine, 0);
  408.     #
  409.     # global15 is used here like so:
  410.     #
  411.     # global15 == 0 while this cog is at work (waiting for line to finish)
  412.     # global15 == 1 upon return
  413.     #
  414.     # As discussed in user0 section, the calling cog can use global15 as a semaphore;
  415.     #
  416.     # As discussed in user1 section, you can also force a line choice.
  417.  
  418.     if (alreadyworking > 0)
  419.     {
  420.         return;
  421.     }
  422.  
  423.     global15 = 0; # init each call
  424.  
  425.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  426.     forceTalk = GetParam(1); # force a choice
  427.     forceLine = GetParam(2); # actual line choice
  428.     
  429.     alreadyworking = 1; # stall multiple calls
  430.  
  431.     if (forceTalk > 0)
  432.     {
  433.         wo_newline = forceLine; # choose this line
  434.         wo_oldline = 0;
  435.     }
  436.  
  437.     call randwontopenlines;
  438.     global15 = 1;
  439.     alreadyworking = 0;
  440.  
  441.     return;
  442.  
  443. # ........................................................................................
  444.  
  445. checkforkey:
  446.  
  447.     keyItem = 0; # init each time thru
  448.  
  449.     for (keyindex = 0; keyindex < keytotal; keyindex = keyindex + 1)
  450.     {
  451.         if (triedItem == key[keyindex])
  452.         {
  453.             keyItem = key[keyindex];
  454.         }
  455.     }
  456.             
  457.     return;
  458.  
  459. # ........................................................................................
  460.  
  461. randrightkeylines:
  462.  
  463.     # NOTE: never say same line twice in a row
  464.     # and say some lines less frequently than others
  465.     
  466.     while (rk_newline == rk_oldline)
  467.     {        
  468.         rk_newline = RandBetween(0, 9);
  469.         if (rk_newline > 7)
  470.         {
  471.             rk_newline = (rk_newline - 3); # 1/10 chance for lines 5 or 6
  472.         }
  473.          else
  474.         {    
  475.             rk_newline = RandBetween(0, 4); # 1/5 chance for lines 0 thru 4
  476.         }
  477.     }
  478.     rk_oldline = rk_newline; # remember choice
  479.     lineindex = rightkeyoffset + rk_newline;
  480.  
  481.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  482.  
  483.     return;
  484.  
  485. # ..............................................................................
  486.  
  487. randwrongkeylines:
  488.  
  489.     while (wk_newline == wk_oldline)
  490.     {        
  491.         wk_newline = RandBetween(0, 3);
  492.     }
  493.     wk_oldline = wk_newline;
  494.     lineindex = wrongkeyoffset + wk_newline; # 1/4 chance
  495.  
  496.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  497.  
  498.     return;
  499.  
  500. # ..............................................................................
  501.  
  502. randwrongitemlines:
  503.  
  504.     while (wi_newline == wi_oldline)
  505.     {        
  506.         wi_newline = RandBetween(0, 19);
  507.         if (wi_newline < 15)
  508.         {    
  509.             wi_newline = RandBetween(0, 3); # ~1/5 chance for lines 0 thru 3
  510.         }
  511.  
  512.         if (wi_newline == 19)
  513.         {
  514.             wi_newline = 6; # 1/20 chance for line 6 
  515.         }
  516.         if (wi_newline > 16)
  517.         {
  518.             wi_newline = 5; # 1/10 chance for line 5 
  519.         }
  520.         if (wi_newline > 14)
  521.         {
  522.             wi_newline = 4; # 1/10 chance for line 4
  523.         }
  524.     }
  525.     wi_oldline = wi_newline;    
  526.     lineindex = wrongitemoffset + wi_newline;
  527.  
  528.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  529.  
  530.     return;
  531.  
  532. # ..............................................................................
  533.  
  534. randlocklines:
  535.  
  536.     while (dl_newline == dl_oldline)
  537.     {        
  538.         dl_newline = RandBetween(0, 19);
  539.         if (dl_newline < 14)
  540.         {    
  541.             dl_newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  542.         }
  543.  
  544.         if (dl_newline > 17)
  545.         {
  546.             dl_newline = (dl_newline - 13); # 1/20 chance for 5 or 6 
  547.         }    
  548.         if (dl_newline > 15)
  549.         {
  550.             dl_newline = 4; # 1/10 chance
  551.         }
  552.         if (dl_newline > 13)
  553.         {
  554.             dl_newline = 3; # 1/10 chance
  555.         }
  556.     }
  557.     dl_oldline = dl_newline;
  558.     lineindex = lockoffset + dl_newline;
  559.  
  560.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  561.  
  562.     return;
  563.  
  564. # ..............................................................................
  565.  
  566. randwontopenlines:
  567.  
  568.     while (wo_newline == wo_oldline)
  569.     {        
  570.         wo_newline = RandBetween(0, 4);
  571.     }
  572.     wo_oldline = wo_newline;
  573.     lineindex = wontopenoffset + wo_newline; # 1/5 chance
  574.  
  575.     PlayVoice(talkerREF, in_sayline[lineindex], 1, 1);
  576.  
  577.     return;
  578.  
  579. end
  580.  
  581.